package elephant.servers.rpcserver;

import elephant.Server;
import elephant.jdbc.DataSourceManager;
import elephant.rpc.server.service.MethodStub;
import elephant.rpc.server.service.RPCServiceInterceptor;

/**
 * 
 * @author skydu
 *
 */
public class RPCServer extends elephant.rpc.server.RPCServer implements Server{

	/**
	 * 
	 */
	public RPCServer(){
		super();
		//
		setRPCServiceInterceptor(new RPCServiceInterceptor() {
			@Override
			public void beforeInvoke(Class<?> interfaceClass, MethodStub stub, Object[] args) {
				boolean useTransaction=stub.implMethod.isAnnotationPresent(Transaction.class);
				DataSourceManager.beforeExcute(useTransaction);
			}
			
			@Override
			public void afterInvoke(Class<?> interfaceClass, MethodStub stub, Object[] args, Throwable e) {
				DataSourceManager.afterExcute();
			}
		});
	}
	
	
}
